/*
 * @Author: Zyunchao 18651805393@163.com
 * @Date: 2022-03-14 10:06:12
 * @LastEditors: Zyunchao 18651805393@163.com
 * @LastEditTime: 2023-06-02 17:26:30
 * @FilePath: /micro-temp-monorepo/_core/microMain/currentMicroTagName.ts
 * @Description: 当前微应用的 <micro-app-xxxx> 唯一标签名，常用于嵌套远程组件的插入
 */
import { v4 as uuidv4 } from 'uuid'
import packInfo from '@ROOT/package.json'
import { Session, hump2Partition } from '@jsjn/utils'

// 自定义 microapp 标签名称不能包含大写字母，即微应用不能驼峰命名，这里将驼峰转换成短横线链接
const currentMicroTagName = `micro-app-${hump2Partition(packInfo.name)}-${uuidv4().replace(/-/g, '')}`

export const CURRENT_MICRO_APP_ID_CACHE = 'CURRENT_MICRO_APP_ID_CACHE'

Session.set(CURRENT_MICRO_APP_ID_CACHE, currentMicroTagName)

export default currentMicroTagName
